<?php

namespace app\beautiful\logic;

use app\beautiful\model\member\MemberCouponModel;



class MemberCouponLogic{

    private $shopId;

    private $memberId;



    public function __construct($shopId,$memberId) {

        $this->shopId = $shopId;

        $this->memberId = $memberId;

    }



    public function getCoupon($coupon,$mCouponType,$type_id,$operate_id = 0)

    {

        $member_coupon_model = new MemberCouponModel();

        $member_coupon_data=[

            'shop_id'=>$this->shopId,

            'member_id'=>$this->memberId,

            'type_id'=>$mCouponType,

            'coupon_id'=>$coupon['coupon_id'],

            'name'=>$coupon['name'],

            'coupon_money'=>$coupon['coupon_money'],

            'money_limit'=>$coupon['money_limit'],

            'valid_bg_time'=>$coupon['valid_bg_time'],

            'valid_end_time'=>$coupon['valid_end_time'],

        ];

        $member_coupon_model->save($member_coupon_data);

        LogsLogic::coupon($this->shopId,$this->memberId,1,$type_id,$member_coupon_model->member_coupon_id,'',$operate_id);

        return true;

    }

}

